package c.e.b.h.e.s;

import c.e.b.h.e.k.x0;
import c.e.b.h.e.s.i.b;
import c.e.b.h.e.s.i.c;
import c.e.b.h.e.s.i.d;
import c.e.b.h.e.s.i.f;
import java.util.Locale;
import java.util.Objects;
import org.json.JSONException;
import org.json.JSONObject;

/* compiled from: SettingsV3JsonTransform */
public class h implements g {
    public f a(x0 x0Var, JSONObject jSONObject) throws JSONException {
        String str;
        long optLong;
        JSONObject jSONObject2 = jSONObject;
        int optInt = jSONObject2.optInt("settings_version", 0);
        int optInt2 = jSONObject2.optInt("cache_duration", 3600);
        JSONObject jSONObject3 = jSONObject2.getJSONObject("fabric");
        JSONObject jSONObject4 = jSONObject2.getJSONObject("app");
        String string = jSONObject4.getString("status");
        boolean equals = "new".equals(string);
        String string2 = jSONObject3.getString("bundle_id");
        String string3 = jSONObject3.getString("org_id");
        if (equals) {
            str = "https://update.crashlytics.com/spi/v1/platforms/android/apps";
        } else {
            str = String.format(Locale.US, "https://update.crashlytics.com/spi/v1/platforms/android/apps/%s", new Object[]{string2});
        }
        String str2 = str;
        Locale locale = Locale.US;
        b bVar = new b(string, str2, String.format(locale, "https://reports.crashlytics.com/spi/v1/platforms/android/apps/%s/reports", new Object[]{string2}), String.format(locale, "https://reports.crashlytics.com/sdk-api/v1/platforms/android/apps/%s/minidumps", new Object[]{string2}), string2, string3, jSONObject4.optBoolean("update_required", false), jSONObject4.optInt("report_upload_variant", 0), jSONObject4.optInt("native_report_upload_variant", 0));
        d dVar = new d(8, 4);
        c cVar = new c(jSONObject2.getJSONObject("features").optBoolean("collect_reports", true));
        long j = (long) optInt2;
        String str3 = "expires_at";
        if (jSONObject2.has(str3)) {
            optLong = jSONObject2.optLong(str3);
        } else {
            Objects.requireNonNull(x0Var);
            optLong = (j * 1000) + System.currentTimeMillis();
        }
        return new f(optLong, bVar, dVar, cVar, optInt, optInt2);
    }
}
